package com.labichaoka.chaoka.ui.bank.bind;

import com.labichaoka.chaoka.entity.BankInfoDtoResponse;
import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.BindBankRequest;
import com.labichaoka.chaoka.entity.GetBankSmsRequest;
import com.labichaoka.chaoka.entity.IDCardResponse;
import com.labichaoka.chaoka.entity.SwitchCardResponse;

/**
 * Created by ruan on 2018/8/8.
 */

public class BankBindPresenterImpl implements BankBindPresenter,BankBindInteractor.OnFinishedListener{

    private BankBindView bankBindView;
    private BankBindInteractor bankBindInteractor;

    public BankBindPresenterImpl(BankBindView bankBindView, BankBindInteractor bankBindInteractor) {
        this.bankBindView = bankBindView;
        this.bankBindInteractor = bankBindInteractor;
    }


    @Override
    public void getIDCardName() {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.getIdCardName(this);
    }

    @Override
    public void bindCard(GetBankSmsRequest request) {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.bindCard(request,this);
    }

    @Override
    public void getSMSCode(GetBankSmsRequest request) {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.getSmsCode(request,this);
    }

    @Override
    public void getBankCardList() {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.getBankCardList(this);
    }

    @Override
    public void bindCardVail(BindBankRequest request) {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.bindCardVail(request,this);
    }

    @Override
    public void scrdSwitchCard(GetBankSmsRequest request) {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.scrdSwitchCard(request,this);
    }

    @Override
    public void submitSwitchCard(BindBankRequest request) {
        if (bankBindView!=null){
            bankBindView.showProgress();
        }
        bankBindInteractor.submitSwitchCard(request,this);
    }

    @Override
    public void behavior(String actionNode) {
        bankBindInteractor.behavior(actionNode);
    }

    @Override
    public void onDestroy() {
        bankBindView=null;
    }

    @Override
    public void onGetSmsCodeSuccessed() {
        bankBindView.hideProgress();
        bankBindView.startCountDown();
    }

    @Override
    public void onGetSmsCodeFailed() {
        bankBindView.hideProgress();
    }

    @Override
    public void onBindCardSuccessed(BaseResponse response) {
        bankBindView.hideProgress();
        bankBindView.submitBankCardInfo(response);
    }

    @Override
    public void onBindCardFailed() {
        bankBindView.hideProgress();
    }

    @Override
    public void onGetIDCardNameSuccessed(IDCardResponse response) {
        bankBindView.hideProgress();
        bankBindView.getIDNameCallback(response);
    }

    @Override
    public void onGetIDCardNameFailed() {
        bankBindView.hideProgress();
    }

    @Override
    public void onGetBankCardListSuccessed(BankInfoDtoResponse response) {
        bankBindView.hideProgress();
        bankBindView.getBankTypeCallBack(response);
    }

    @Override
    public void onGetBankCardListFailed() {
        bankBindView.hideProgress();
    }

    @Override
    public void onBindCardVailSucc(BaseResponse response) {
        bankBindView.hideProgress();
        bankBindView.bindCardVail(response);
    }

    @Override
    public void onBindCardVailFailed() {
        bankBindView.hideProgress();
    }

    @Override
    public void onScrdSwitchCardSucc(SwitchCardResponse response) {
        bankBindView.hideProgress();
        bankBindView.scrdSwitchCardCallback(response);
    }

    @Override
    public void onScrdSwitchCardFailed() {
        bankBindView.hideProgress();
    }

    @Override
    public void onSubmitSwitchCardSucc(SwitchCardResponse response) {
        bankBindView.hideProgress();
        bankBindView.submitSwitchCardCallback(response);
    }

    @Override
    public void onSubmitSwitchCardFailed() {
        bankBindView.hideProgress();
    }
}
